import java.util.ArrayList;
public class deom{
        public static void main(String[] args) throws IndexOutOfBoundsException{
            ArrayList<String> arrays = new ArrayList<>();
            arrays.add("玉");
            arrays.add("娃");
            arrays.add("给");
            arrays.add("利");

            //public static void main(String[] args) {
            Runnable printA = new PrintChar("你好!", 50);
            Runnable printlist = new Printlist(arrays);
            Runnable printB = new PrintChar("再见", 50);

            Thread thread1 = new Thread(printA);
            Thread thread2 = new Thread(printlist);
            Thread thread3 = new Thread(printB);

            thread1.start();
            thread2.start();
            thread3.start();
        }  }
    class PrintChar implements Runnable {
        private String chartToPrint;
        private int times;

        public PrintChar(String c, int t) {
            chartToPrint = c;
            times = t;
        }

        @Override
        public void run() {
            for (int i = 0; i < times; i++) {
                System.out.println(chartToPrint);
            }
        }
    }

    class Printlist implements Runnable{
        private ArrayList list;
        public Printlist(ArrayList list1){list=list1;}

        public void run(){
            for (int i =0;i<list.size();i++){
                System.out.println(" "+list.get(i));
            }

        }
    }
    class PrintNum implements Runnable {
        private int lastNum;

        public PrintNum(int n) {
            lastNum = n;

        }



        public void run() {
            int lastNum = 0;
            int i;
            for (i = 0; i <= lastNum; i++) {
                System.out.println(" " + i);
            }
        }

    }

